package com.framework.common.utils;

/**
 * 计算星座的工具类
 * @author xfy
 * @date 2020/10/21
 */
public class ConstellationUtil {
    /**
     * 根据yyyy-MM-dd或yyyy/MM/dd或yyyy年MM月dd日格式获取星座
     * @param key
     * @return
     */
    public static String getConstellation(String key)
    {
        Integer month=Integer.valueOf(key.substring(5,7));
        Integer day = Integer.valueOf(key.substring(8,10));
        return getAstro(month,day);
    }

    public static String getAstro(Integer month,Integer day)
    {
        String s="魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯";
        Integer[] arr={20,19,21,21,21,22,23,23,23,23,22,22};
        Integer num = month*2-(day<arr[month-1]?2:0);
        return s.substring(num,num+2);
    }
}
